package packets.c2spackets;

import datatypes.MCAnimation;
import network.MCConnection;
import exceptions.UnrecoverableException;
import packets.PacketHandler;
import world.WorldState;

/**
 * Send when an entity performs an animation-action.
 * The receiving of a packet updates it for the player.
 */
public class P0x12 extends PacketHandler {

	public P0x12(WorldState worldstate) {
		super(worldstate);
	}

	@Override
	public void handle(MCConnection conn) throws UnrecoverableException {
		/*int eid = */conn.r.readInt();
		MCAnimation animation = MCAnimation.getAnimation(conn.r.read());
		
		if(/*conn.getPlayer().geteid() == eid && */(animation == MCAnimation.SWINGARM || animation == MCAnimation.LEAVE_BED)) {
			conn.getPlayer().setAnimation(animation);
		}/* else {
			//TODO: HACKATTEMPT?
			conn.disconnect();
		}*/
		
	}
}
